<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: HttpClientRequest</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Class: HttpClientRequest</h1>
    
    



<section>
    
<header>
    <h2>
        <span class="ancestors"><a href="http.html">vertx/http</a>.</span>
    
    HttpClientRequest
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
<dt>
    <h4 class="name" id="HttpClientRequest"><span class="type-signature"></span>new HttpClientRequest<span class="signature">()</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>
Represents a client-side HTTP request.  Instances are created by an
<a href="http.HttpClient.html"><code>module:vertx/http.HttpClient</code></a> instance, via one of the methods
corresponding to the specific HTTP methods, or the generic <a href="http.HttpClient.html#request"><code>module:vertx/http.HttpClient#request</code></a> method.
</p>
<p>
Once a request has been obtained, headers can be set on it, and data can be
written to its body if required. Once you are ready to send the request, the
<a href="http.HttpClientRequest.html#end"><code>module:vertx/http.HttpClientRequest#end</code></a> method should be called.
</p>
<p>
The headers of the request are actually sent either when the 
<a href="http.HttpClientRequest.html#end"><code>module:vertx/http.HttpClientRequest#end</code></a> method is called, or,
when the first part of the body is written, whichever
occurs first.
</p>
<p>
This class supports both chunked and non-chunked HTTP.
It mixes in <a href="WriteStream.html"><code>WriteStream</code></a> so it can be used with
<a href="pump-Pump.html"><code>module:vertx/pump~Pump</code></a> to pump data with flow control.
</p>
<p>
An example of using this class is as follows:
<p>
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>org.vertx.java.core.http.HttpClientRequest</code></td>
            
            
            <td class="type">
            
            </td>
            
            
            
            
            
            <td class="description last">the underlying Java proxy</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1147">line 1147</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
        <h5>Example</h5>
        
    <pre class="prettyprint"><code>var console = require('vertx/console');

var req = httpClient.post("/some-url", function(response) {
    console.log("Got response: " + response.statusCode);
  }
});

req.headers().add("Content-Length", 5);
req.end(new Buffer('hello');</code></pre>

    
</dd>

    
    </div>
    
    
    
    
        <h3 class="subsection-title">Mixes In</h3>
        
        <ul>
            <li><a href="WriteStream.html">WriteStream</a></li>
        </ul>
    
    
    
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="chunked"><span class="type-signature"></span>chunked<span class="signature">(<span class="optional">chunked</span>)</span><span class="type-signature"> &rarr; {boolean|<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Sets or gets whether the request should used HTTP chunked encoding or not.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>chunked</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">If val is true, this request will use HTTP
chunked encoding, and each call to write to the body will correspond to a
new HTTP chunk sent on the wire. If chunked encoding is used the HTTP
header 'Transfer-Encoding' with a value of 'Chunked' will be automatically
inserted in the request. If <code>chunked</code> is not provided, returns
the current value.</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1163">line 1163</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">boolean</span>
|

<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="continueHandler"><span class="type-signature"></span>continueHandler<span class="signature">(handler)</span><span class="type-signature"> &rarr; {<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        If you send an HTTP request with the header 'Expect' set to the value
'100-continue' and the server responds with an interim HTTP response with
a status code of '100' and a continue handler has been set using this
method, then the handler will be called.  You can then continue to write
data to the request body and later end it. This is normally used in
conjunction with the send_head method to force the request header to be
written before the request has ended.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>handler</code></td>
            
            
            <td class="type">
            
                
<span class="param-type"><a href="global.html#Handler">Handler</a></span>


            
            </td>
            
            
            
            
            
            <td class="description last">The handler</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1223">line 1223</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="end"><span class="type-signature"></span>end<span class="signature">(<span class="optional">chunk</span>, <span class="optional">encoding</span>)</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Ends the request. If no data has been written to the request body, and
send_head has not been called then the actual request won't get written
until this method gets called.  Once the request has ended, it cannot be
used any more, and if keep alive is true the underlying connection will
be returned to the HttpClient pool so it can be assigned to another request.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>chunk</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">The data to write</td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>encoding</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">The charset to use if data is written</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1250">line 1250</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="headers"><span class="type-signature"></span>headers<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="multi_map-MultiMap.html">module:vertx/multi_map~MultiMap</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Returns the headers for the requests
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1177">line 1177</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    The headers
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="multi_map-MultiMap.html">module:vertx/multi_map~MultiMap</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="putHeader"><span class="type-signature"></span>putHeader<span class="signature">(name, value)</span><span class="type-signature"> &rarr; {<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Put a header on the request
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>name</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
            
            
            
            <td class="description last">The header name</td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>value</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
            
            
            
            <td class="description last">The header value</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1191">line 1191</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="sendHead"><span class="type-signature"></span>sendHead<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Forces the head of the request to be written before end is called on the
request. This is normally used to implement HTTP 100-continue handling.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1235">line 1235</a>
    </li></ul></dd>
    
    
    
    
    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li>module:vertx/http.HttpClientRequest#continue_handler</li>
        </ul>
    </dd>
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="timeout"><span class="type-signature"></span>timeout<span class="signature">(timeout)</span><span class="type-signature"> &rarr; {<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Set's the amount of time after which if a response is not received an exception
will be sent to the exception handler of this request. Calling this method more than once
has the effect of canceling any existing timeout and starting the timeout from scratch.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>timeout</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">number</span>


            
            </td>
            
            
            
            
            
            <td class="description last">The amount of time in milliseconds to wait before timing out</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1270">line 1270</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="write"><span class="type-signature"></span>write<span class="signature">(chunk, <span class="optional">encoding</span>)</span><span class="type-signature"> &rarr; {<a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Write to the request body
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>chunk</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
                <td class="attributes">
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">the data to write</td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>encoding</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">the data encoding (default is UTF-8)</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line1202">line 1202</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.HttpClientRequest.html">module:vertx/http.HttpClientRequest</a></span>


	</dd>
</dl>

        
    
    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-vertx.html">vertx</a></li><li><a href="buffer.html">vertx/buffer</a></li><li><a href="console.html">vertx/console</a></li><li><a href="container.html">vertx/container</a></li><li><a href="event_bus.html">vertx/event_bus</a></li><li><a href="file_system.html">vertx/file_system</a></li><li><a href="http.html">vertx/http</a></li><li><a href="multi_map.html">vertx/multi_map</a></li><li><a href="net.html">vertx/net</a></li><li><a href="parse_tools.html">vertx/parse_tools</a></li><li><a href="pump.html">vertx/pump</a></li><li><a href="shared_data.html">vertx/shared_data</a></li><li><a href="sockjs.html">vertx/sockjs</a></li><li><a href="timer.html">vertx/timer</a></li></ul><h3>Externals</h3><ul><li><a href="InetSocketAddress.html">InetSocketAddress</a></li><li><a href="Buffer_.html">Buffer</a></li><li><a href="RecordParser.html">RecordParser</a></li><li><a href="SockJSSocket.html">SockJSSocket</a></li></ul><h3>Classes</h3><ul><li><a href="buffer-Buffer.html">Buffer</a></li><li><a href="file_system.AsyncFile.html">AsyncFile</a></li><li><a href="http.HttpClient.html">HttpClient</a></li><li><a href="http.HttpClientRequest.html">HttpClientRequest</a></li><li><a href="http.HttpClientResponse.html">HttpClientResponse</a></li><li><a href="http.HttpServer.html">HttpServer</a></li><li><a href="http.HttpServerFileUpload.html">HttpServerFileUpload</a></li><li><a href="http.HttpServerRequest.html">HttpServerRequest</a></li><li><a href="http.HttpServerResponse.html">HttpServerResponse</a></li><li><a href="http.RouteMatcher.html">RouteMatcher</a></li><li><a href="http.WebSocket.html">WebSocket</a></li><li><a href="multi_map-MultiMap.html">MultiMap</a></li><li><a href="net.NetClient.html">NetClient</a></li><li><a href="net.NetServer.html">NetServer</a></li><li><a href="net.NetSocket.html">NetSocket</a></li><li><a href="pump-Pump.html">Pump</a></li><li><a href="sockjs.SockJSServer.html">SockJSServer</a></li></ul><h3>Mixins</h3><ul><li><a href="ClientSSLSupport.html">ClientSSLSupport</a></li><li><a href="ReadStream.html">ReadStream</a></li><li><a href="ServerSSLSupport.html">ServerSSLSupport</a></li><li><a href="ServerTCPSupport.html">ServerTCPSupport</a></li><li><a href="SSLSupport.html">SSLSupport</a></li><li><a href="TCPSupport.html">TCPSupport</a></li><li><a href="WriteStream.html">WriteStream</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Wed Jul 17 2013 20:27:23 GMT+0100 (BST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>